Conversation
b4cf32f to
af783b0
Compare
| } | ||
| if value is None: | ||
| print("Environment variables (set by user):") | ||
| print("Environment variables (set by user):") # type: ignore[unreachable] |
There was a problem hiding this comment.
value is not Optional, so in theory it cannot be None.
Do we still want to defend against an actual None?
| logger.debug("Injecting package %s", package_spec) | ||
|
|
||
| if not venv_dir.exists() or not next(venv_dir.iterdir()): | ||
| if not venv_dir.exists() or next(venv_dir.iterdir(), None) is None: |
There was a problem hiding this comment.
venv_dir.iterdir() yields Path which does not implement __bool__ or __len__ so it will always be true in boolean context. We might want to defend against StopIteration exceptions raised by next().
| """Returns pipx exit code""" | ||
|
|
||
| if not venv_dir.exists() or not next(venv_dir.iterdir()): | ||
| if not venv_dir.exists() or next(venv_dir.iterdir(), None) is None: |
There was a problem hiding this comment.
venv_dir.iterdir() yields Path which does not implement __bool__ or __len__ so it will always be true in boolean context. We might want to defend against StopIteration exceptions raised by next().
| package_name = app | ||
|
|
||
| content = None if spec is not None else maybe_script_content(app, is_path) | ||
| content = None if spec is not None else maybe_script_content(app, is_path) # type: ignore[redundant-expr] |
There was a problem hiding this comment.
spec is not Optional, so in theory it cannot be None.
Do we still want to defend against an actual None?
| run_script(content, app_args, python, pip_args, venv_args, verbose, use_cache) | ||
| else: | ||
| package_or_url = spec if spec is not None else app | ||
| package_or_url = spec if spec is not None else app # type: ignore[redundant-expr] |
| ) | ||
| elif args.command == "runpip": | ||
| if not venv_dir: | ||
| if not venv_dir: # type: ignore[truthy-bool] |
There was a problem hiding this comment.
In theory, venv_dir cannot be None.
Do we still want to defend against an actual None?
8d93445 to
766f8c4
Compare
|
|
||
| if pip_args is None: | ||
| pip_args = [] | ||
| pip_args = [] # type: ignore[unreachable] |
There was a problem hiding this comment.
pip_args is not Optional, so in theory it cannot be None.
Do we still want to defend against an actual None?
766f8c4 to
40c7227
Compare
40c7227 to
40f69a5
Compare
40f69a5 to
1637bb4
Compare
1637bb4 to
8602a6a
Compare
4279653 to
5cc32a6
Compare
gaborbernat
left a comment
There was a problem hiding this comment.
Looks like you'll need to fix the CI.
RF003: src directory doesn't need to be specified anymore (0.6+) Ruff now (0.6+) looks in the src directory by default. The src setting doesn't need to be specified if it's just set to `["src"]`.
a439c93 to
ba3ce1d
Compare
MY103: MyPy warn unreachable Must have `warn_unreachable` (true/false) to pass this check. There are occasionally false positives (often due to platform or Python version static checks), so it's okay to set it to false if you need to. But try it first - it can catch real bugs too. MY104: MyPy enables ignore-without-code Must have `"ignore-without-code"` in `enable_error_code = [...]`. This will force all skips in your project to include the error code, which makes them more readable, and avoids skipping something unintended. MY105: MyPy enables redundant-expr Must have `"redundant-expr"` in `enable_error_code = [...]`. This helps catch useless lines of code, like checking the same condition twice. MY106: MyPy enables truthy-bool Must have `"truthy-bool"` in `enable_error_code = []`. This catches mistakes in using a value as truthy if it cannot be falsy.
ba3ce1d to
bf881a1
Compare
changelog.d/(if the patch affects the end users)Summary of changes
More verbose MyPy and resulting fixes.
Test plan
Pass CI.